<div style="margin: auto">
    <form id="album_add_form" class="layui-form layui-form-pane" method="post" th:action="${action}">
        <input type="hidden" name="id" th:value="${album.id}">
        <div style="margin: 40px;">
            <div class="layui-form-item">
                <label class="layui-form-label">名称</label>
                <div class="layui-input-block">
                    <input id="album_add_name" autocomplete="off" class="layui-input" name="name" lay-verify="required" th:value="${album.name}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input id="album_add_state" autocomplete="off" class="layui-input" name="state" th:value="${album.state}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label" style="height: 100px;">说明</label>
                <div class="layui-input-block">
                    <textarea placeholder="请输入内容" id="album_add_introduce" class="layui-textarea" name="introduce" th:value="${album.introduce}" th:text="${album.introduce}"></textarea>
                </div>
            </div>
            <div class="layui-footer" style="margin: auto;display:none">
                <button id="album_add_submit" type="submit" class="layui-btn" lay-submit lay-filter="album_add_submit">立即提交</button>
            </div>
        </div>
    </form>
</div>

<script type="text/javascript">
    $(function () {
        $('#album_add_form').submit(function () {
            var action = $(this).attr('action');
            $.ajax({
                url: action,
                type: 'post',
                data: $(this).serialize(),
                success:function(result){
                    if (result.state == "success"){
                        //album_index_js.flow_init(album_index_js.pno, album_index_js.psize);
                        if (action.indexOf('update') > 0){
                            album_index_js.item.name = $('#album_add_name').val();
                            album_index_js.item.state = $('#album_add_state').val();
                            album_index_js.item.introduce = $('#album_add_introduce').val();
                            $('#' + album_index_js.item.id).attr('data-name', album_index_js.item.name);
                            $('#' + album_index_js.item.id).attr('data-state', album_index_js.item.state);
                            $('#' + album_index_js.item.id).attr('data-introduce', album_index_js.item.introduce);
                            var _span = $("#" + album_index_js.item.id).find('.album-item-text');
                            $(_span[0]).html(album_index_js.item.name);
                        }
                        album_index_js.layer.close(album_index_js.layerIndex);
                        album_index_js.layer.msg(result.message);
                    }else {
                        album_index_js.layer.msg(result.message);
                    }
                }});
            return false;
        });
    });
</script>